<?php
/**
 * Created by 王跃达.
 * User: 小马出行
 * Date: 2017/8/24
 * Time: 16:17
 */

namespace app\api\model;


use think\Db;
use think\Model;

class ZoneModel extends Model
{


    public function __construct()
    {
        parent::__construct();

    }

    /*
     * 通过坐标获取信息
     */
    public function getZoneByLocal($city, $district)
    {
        //$info = Db::name("zone")->field("zone_id,zone_name,is_use")->where(array("zone_name" => $district))->find();
        $info = Db::name("zone")->where(array("zone_name" => $district))->find();
        if (empty($info)) {
            $info = Db::name("zone")->where("zone_name", $city)->find();
        }
        return $info;
    }

    public function getZone($map,$field='*',$flag = true,$page=1,$limit=10)
    {
        return $flag ? Db::name('zone')->where($map)->field($field)->page($page,$limit)->select()
            : Db::name('zone')->where($map)->field($field)->find();
    }

}